#if !defined(AFX_8085DISPLAY_H__E786C672_837E_11D2_806D_00A0C91F41A7__INCLUDED_)
#define AFX_8085DISPLAY_H__E786C672_837E_11D2_806D_00A0C91F41A7__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// 8085Display.h : header file
//

#include "8085Object.h"
#include "8085Doc.h"
#include "InstructionBox.h"
#include "MemDumpBox.h"
#include "RegisterBox.h"
#include "FlagBox.h"
#include "StackDumpBox.h"
#include "PortDumpBox.h"
#include "ColourText.h"
#include "CommonObject.h"
#include "MyToolBar.h"
#include "LedDisplay.h"

/////////////////////////////////////////////////////////////////////////////
// C8085Display dialog

class C8085Display : public CDialog , public virtual CCommonObject
{
// Construction
public:
	C8085Display(CWnd* pParent = NULL);   // standard constructor
	BOOL CreateAll(UINT nIDTemplate, CWnd* pParentWnd = NULL );
	void CloseDialog();
	void Init();

    // Implementation
public:
	word AddressAtIndex();
	void QuitSimulator();
    /////////////////////////////////////////
    // functions to step, run etc
	void SimulateOneInstruction();
    void Animate(int nDelay);
	void StepOut();
	void Run();
	void RunToCursor();
    void RunToCursor(word addr);
	void StepInto(BOOL bRedraw=TRUE);
	void StepOver();

    /////////////////////////////////////////
    // breakpoints
	void RemoveTempBkPt();
	void AddTempBkPt(word addr);

    /////////////////////////////////////////
    // GUI Update
	void CleanupUserInterface();
	void CleanUp(CMyException& cm);
	void Adjust();
	void SetRunningText();
	void SetReadyText();
	void ChangeButtonState();
    void ShowDisAssemblyPosition(word address);
	long ToggleLedWindow(UINT=0, long=0);
	long RefreshStackBox(UINT=0, long=0);
	long RefreshInstructionBox(UINT=0, long=0);
	void Refresh();     // update everything
    /////////////////////////////////////////
    // update the various boxes
    inline void DisplayPortDump()  {m_PortDump.Refresh();  }
    inline void DisplayStackDump() { m_StackDump.Refresh(); }
    inline void DisplayMemoryDump() { m_MemoryDump.Refresh(); }
    inline void DisplayInstructions() {m_Instructions.Refresh();}
    inline void DisplayFlags()      {m_Flags.Refresh();}
    inline void DisplayRegisters()  {m_Registers.Refresh();}


    /////////////////////////////////////////
    virtual void OnCancel();
    long OnVKeyDown(UINT=0,long=0); // to handle VK_F10 etc for debugging
    long OnVKeyUp(UINT=0,long=0); // to handle VK_F10 etc for debugging
    inline BOOL IsAnimating()  {return GetDocument()->IsAnimating();}
	int GetAnimationDelay();
      
    friend DWORD WINAPI AnimateRoutine(LPVOID v);

// Dialog Data
	//{{AFX_DATA(C8085Display)
	enum { IDD = IDD_8085DISPLAY };
	CColourText	    m_szPortsText;
	CPortDumpBox    m_PortDump;
	CColourText	    m_cStackText;
	CStackDumpBox   m_StackDump;
	CColourText	    m_cRegisterText;
	CColourText	    m_cMemDumpText;
	CColourText	    m_cFlagText;
	CColourText	    m_cInstructionText;
	CMemDumpBox     m_MemoryDump;
	CRegisterBox	m_Registers;
	CFlagBox	    m_Flags;
	CInstructionBox m_Instructions;
	CString	        m_szInstructions;
	CString	        m_szMemoryDump;
	CString	        m_szRegisters;
	//}}AFX_DATA


// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(C8085Display)
	public:
	virtual BOOL DestroyWindow();
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	virtual void PostNcDestroy();
	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
	//}}AFX_VIRTUAL

// Implementation
protected:

	// Generated message map functions
	//{{AFX_MSG(C8085Display)
	virtual void OnOK();
	virtual BOOL OnInitDialog();
	afx_msg void OnButtonRefresh();
	afx_msg void OnButtonAnimate();
	afx_msg void OnButtonStop();
	afx_msg void OnButtonRun();
    afx_msg void OnButtonStepInto();
	afx_msg void OnButtonStepOver();
	afx_msg void OnButtonStepOut();
	afx_msg void OnButtonRunto();
	afx_msg void OnButtonQuitSimulator();
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnButtonShowLed();
	afx_msg void OnUpdateButtonStop(CCmdUI* pCmdUI);
	afx_msg void OnClose();
	afx_msg void OnButtonToggleBkpt();
	afx_msg void OnButtonEnableDisableBkpt();
	afx_msg void OnAccelCloseSimulation();
	//}}AFX_MSG
    BOOL OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult);
	DECLARE_MESSAGE_MAP()
    
    //data members
protected:
    DWORD       m_ThreadID;
    HANDLE      m_hThreadHandle;
    int         m_nDelayValue;
    CMyToolBar  m_cToolBar;
    CString     m_szWindowText;     // the string appearing
    BOOL        m_bLEDButtonState;  // state of the LED toolbutton
    CLedDisplay *m_pLedDisplay;
    BOOL        m_bShiftDown;       // TRUE if Shift is in depressed state
    BOOL        m_bCtrlDown;        // TRUE if CTRL is in depressed state

    // data used by step over and run to cursor functions
    BOOL        m_bTempBkPt;
    word        m_wAddr;
    BOOL        m_bExceptionCaught; // set to TRUE if exception is caught

private:
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_8085DISPLAY_H__E786C672_837E_11D2_806D_00A0C91F41A7__INCLUDED_)
